package com.lizonghui.googleplay.factory;

import com.lizonghui.googleplay.manager.ThreadPoolProxy;

/**
 * Created by Administrator on 2016/6/18.
 * 线程池代理生产工厂
 */
public class ThreadPoolProxyFactory {
   static ThreadPoolProxy mNormalThreadPoolProxy;
    static ThreadPoolProxy mDownLoadThreadPoolProxy;


    /**
     * 返回普通线程池代理
     * @return
     */
    public static ThreadPoolProxy createNormalThreadPoolProxy(){
        //双重判断，保持单例模式
        if(mNormalThreadPoolProxy == null){
            synchronized (ThreadPoolProxyFactory.class){
                if(mNormalThreadPoolProxy == null){
                    //同时执行5个任务，最多5个任务，执行3秒
                    mNormalThreadPoolProxy = new ThreadPoolProxy(5,5,3000);
                }
            }
        }
        return mNormalThreadPoolProxy;
    }

    /**
     * 返回下载线程池代理
     */
    public static ThreadPoolProxy createDownLoadThreadPoolProxy(){
        if(mDownLoadThreadPoolProxy == null){
            synchronized (ThreadPoolProxyFactory.class){
                if(mDownLoadThreadPoolProxy == null){
                    //同时执行3个任务，最多3个任务。我们使用的是无界队列，时间参数无意义，因为有任务就会执行.这里只是写个形式
                    mDownLoadThreadPoolProxy = new ThreadPoolProxy(3,3,3000);
                }
            }
        }
        return mDownLoadThreadPoolProxy;
    }
}
